import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { allProjects } from '#/api/clinical/project';
import { getPopupContainer } from '@vben/utils';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '模板名称',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  {
    title: '模板key',
    field: 'key',
    width: 300,
  },
  {
    title: '模板名称',
    field: 'name',
  },
  {
    title: '创建时间',
    field: 'createTime',
  },
  {
    title: '创建人',
    field: 'createByName',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];
export const modalSchema: FormSchemaGetter = () => [
  {
    label: '问卷key',
    fieldName: 'key',
    component: 'Input',
    rules: 'required',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '问卷名称',
    fieldName: 'name',
    component: 'Input',
    rules: 'required',
  },
  {
    component: 'ApiSelect',
    componentProps: {
      getPopupContainer,
      api: () => allProjects(),
      fieldNames: {
        label: 'name',
        value: 'id',
      },
    },
    fieldName: 'researchProjectId',
    label: '所属项目',
    rules: 'required',
  },
];
